package problems.solved;

import utils.Utils;

public class Problem41 {
	private static final long LOWER = 1L;
	private static final long UPPER = 7654321L; //apparently, 8- and 9-digit numbers are never primes

	public static void main(String[] args) {
		long amount = UPPER - LOWER;

		for (long i = UPPER; i >= LOWER; i-=2) {
			if (i % 20000000 == 1) {
				Utils.printProgress(amount - (i-LOWER), amount);
			}
			final String number = Long.toString(i);
			int length = number.length();
			if (Utils.isPandigital(number, length) && Utils.isPrime(i)) {
				System.out.printf("Found %d-pandigital prime: %s%n", length, number);
				return;
			}
		}
		System.out.println("Not found");
	}
}
